home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / shelfEditorDialog.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  40.2 KB  |  1,455 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // Copyright (C) 1997-2001 Alias|Wavefront,
  18. // a division of Silicon Graphics Limited.
  19. //
  20. // The information in this file is provided for the exclusive use of the
  21. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  22. // and incorporate this code into other products for purposes authorized
  23. // by the Alias|Wavefront license agreement, without fee.
  24. //
  25. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  26. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  27. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  28. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  29. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  30. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  31. // PERFORMANCE OF THIS SOFTWARE.
  32. //
  33.  
  34. // For mac, we need add an extra layout, i.e Menubar layout. That is the reason
  35. // for introducing `about -mac` code at many places
  36.  
  37. global proc shelfEdRepeatableFlagChanged() {
  38.     global string $gShelfTopLevel;
  39.  
  40.     string $shelfList, $itemList, $cbg1;
  41.     if(`about -mac`){
  42.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  43.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  44.         $cbg1 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|cbg1";
  45.     }else{
  46.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  47.         $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  48.         $cbg1 =      "shelfEditorWin|fl|topTab|fl3|cbg1";
  49.     }
  50.     string $item;
  51.     string $itemStr;
  52.     string $retVal[];
  53.     string $selected[];
  54.     string $type;
  55.     int $index;
  56.     int $itemIndex[];
  57.     int $i, $nArr;
  58.     int $newVal = false;
  59.  
  60.     $retVal = `textScrollList -q -si $itemList`; 
  61.     if (size($retVal) > 0) {
  62.         $itemStr = $retVal[0];
  63.         //  get new value of the flag
  64.         //
  65.         $newVal = `checkBoxGrp -query -value1 $cbg1`;
  66.  
  67.         //  get real item name
  68.         //
  69.         $itemIndex = `textScrollList -q -sii $itemList`;
  70.         $index = $itemIndex[0] - 1;
  71.         $selected = `textScrollList -q -si $shelfList`;
  72.         $retVal = `shelfLayout -q -ca $selected[0]`;
  73.         $item = ($gShelfTopLevel + "|" + $selected[0] + "|" + $retVal[$index]);
  74.         $type = `objectType $item`;
  75.  
  76.         switch ($type) {
  77.         case "toolButton":
  78.             //toolButton -e -iol $newName $item;
  79.             break;
  80.         case "shelfButton":
  81.             //shelfButton -e -iol $newName $item;
  82.             shelfButton -e -ecr $newVal $item;
  83.             break;
  84.         }    
  85.     }
  86. }
  87.  
  88.  
  89. global proc shelfEditorDialog () 
  90. {
  91.     global string $gShelfTopLevel;
  92.     global int    $gShelfCreated;
  93.     
  94.     string $shelfList, $itemList, $tfg;
  95.     string $retVal[], $form;
  96.     int $col1width = 180;
  97.  
  98.     //    Check if the Shelf has been created yet.  If not, then build it so
  99.     //    the Shelf Editor actually has something to work with.
  100.     //
  101.     if (!$gShelfCreated) {
  102.         buildShelves();
  103.         $gShelfCreated = true;
  104.     }
  105.     
  106.     if (!`window -exists shelfEditorWin`) {
  107.  
  108.         window -t "Shelves" -iconName "Shelves" 
  109.             -menuBar true  
  110.             shelfEditorWin;
  111.  
  112.             //  Add an options menu for shelf preferences
  113.             //
  114.             menu -label "Options";
  115.             
  116.                 //
  117.                 //  Icon style
  118.                 //
  119.                 radioMenuItemCollection;
  120.                 menuItem -l "Icon Only"
  121.                     -rb off 
  122.                     -c "setShelfStyle \"iconOnly\" \"Small\"; optionVar -sv shelfItemStyle \"iconOnly\""
  123.                     iconOnlyItem;
  124.                 menuItem -l "Icon/Text Below"
  125.                     -rb off 
  126.                     -c "setShelfStyle \"iconAndTextVertical\" \"Small\"; optionVar -sv shelfItemStyle \"iconAndTextVertical\""
  127.                     iconTextBelowItem;
  128.                 menuItem -l "Icon/Text Beside"
  129.                     -rb off 
  130.                     -c "setShelfStyle \"iconAndTextHorizontal\" \"Small\"; optionVar -sv shelfItemStyle \"iconAndTextHorizontal\""
  131.                     iconTextBesideItem;
  132.  
  133.                 // set the initial value
  134.                 string $shelfItemLayout = `optionVar -q shelfItemStyle`;
  135.                 if ("textOnly" == $shelfItemLayout) {
  136.                     // Don't support anymore so go for icon only
  137.                     menuItem -e -rb on iconOnlyItem;
  138.                 } else if ("iconAndTextVertical" == $shelfItemLayout) {
  139.                     menuItem -e -rb on iconTextBelowItem;
  140.                 } else if ("iconAndTextHorizontal" == $shelfItemLayout) {
  141.                     menuItem -e -rb on iconTextBesideItem;
  142.                 } else {
  143.                     // default to icon only
  144.                     menuItem -e -rb on iconOnlyItem;
  145.                 }
  146.  
  147.                 //
  148.                 //  shelf saving
  149.                 //
  150.                 menuItem -divider true;
  151.                 radioMenuItemCollection;
  152.                 menuItem -l "Save Automatically"
  153.                     -rb off 
  154.                     -c "optionVar -iv isShelfSave 1" 
  155.                     autoSaveItem;
  156.                 menuItem -l "Save Only on Request"
  157.                     -rb off 
  158.                     -c "optionVar -iv isShelfSave 0" 
  159.                     requestSaveItem;
  160.  
  161.                 // Set the initial value
  162.                 if (`optionVar -q isShelfSave`) {
  163.                     menuItem -e -rb on autoSaveItem;
  164.                 } else {
  165.                     menuItem -e -rb on requestSaveItem;
  166.                 }
  167.  
  168.             menu -label "Help" -helpMenu true;
  169.                 menuItem -label "Help on Shelves..."
  170.                     -enableCommandRepeat false
  171.                     -command "showHelp ShelfEditor";
  172.  
  173.             setParent -m ..;
  174.  
  175.             formLayout fl;
  176.                 tabLayout -preSelectCommand "shelfEdTabPreSelect" topTab;
  177.                     $form = `formLayout fl2`;
  178.  
  179.                             $shelfList = `textScrollList -nr 9
  180.                                 -w $col1width 
  181.                                 -allowMultiSelection false
  182.                                 -selectCommand "shelfEdShelfChanged" tsl`;
  183.                                 
  184.                             string $buttonForm = `formLayout sForm`;
  185.  
  186.                                 button -l "Move Up"
  187.                                     -c "shelfEdMoveShelf 1" moveUpBtn;
  188.  
  189.                                 button -l "Move Down"
  190.                                     -c "shelfEdMoveShelf 0" moveDownBtn;
  191.  
  192.                                 button -l "New Shelf" 
  193.                                     -c "shelfEdNewShelf" newShelfBtn;
  194.  
  195.                                 button -l "Delete Shelf"
  196.                                     -c "shelfEdDeleteShelf" deleteShelfBtn;
  197.  
  198.                             setParent ..;
  199.  
  200.                             formLayout -e 
  201.                                 -af moveUpBtn top 7
  202.                                 -ap moveUpBtn left 0 2
  203.                                 -ap moveUpBtn right 0 24
  204.                                 -an moveUpBtn bottom 
  205.                                 
  206.                                 -af moveDownBtn top 7
  207.                                 -ap moveDownBtn left 0 25
  208.                                 -ap moveDownBtn right 0 49
  209.                                 -an moveDownBtn bottom
  210.                                 
  211.                                 -af newShelfBtn top 7
  212.                                 -ap newShelfBtn left 0 50
  213.                                 -ap newShelfBtn right 0 74
  214.                                 -an newShelfBtn bottom
  215.                                 
  216.                                 -af deleteShelfBtn top 7
  217.                                 -ap deleteShelfBtn left 0 75
  218.                                 -ap deleteShelfBtn right 0 98
  219.                                 -an deleteShelfBtn bottom
  220.                                 $buttonForm;
  221.                                 
  222.                             $tfg = `textFieldGrp -l "Name:" 
  223.                                 -w $col1width
  224.                                 -cw 1 120 
  225.                                 -cat 1 "right" 5
  226.                                 -cat 2 "both" 0
  227.                                 -cc "shelfEdNameChanged" 
  228.                                 tfg`;
  229.  
  230.                     formLayout -edit
  231.                         -attachForm    $shelfList  "top"    5
  232.                         -attachForm    $shelfList  "left"   5 
  233.                         -attachControl $shelfList  "bottom" 0 $buttonForm
  234.                         -attachForm    $shelfList  "right"  5 
  235.  
  236.                         -attachNone    $buttonForm "top"
  237.                         -attachForm    $buttonForm "left"   0 
  238.                         -attachControl $buttonForm "bottom" 7 $tfg
  239.                         -attachForm    $buttonForm "right"  0 
  240.  
  241.                         -attachNone    $tfg        "top"
  242.                         -attachForm    $tfg        "left"   0 
  243.                         -attachForm    $tfg        "bottom" 5
  244.                         -attachForm    $tfg        "right"  0 
  245.                         $form;
  246.                 if(`about -mac`){
  247.                     setParent shelfEditorWin|shelfEditorWin|fl|topTab;
  248.                 }else{
  249.                     setParent shelfEditorWin|fl|topTab;
  250.                 }
  251.                 $form = `formLayout fl3`;
  252.                 if(`about -mac`){
  253.                     tabLayout -e -sti 2 shelfEditorWin|shelfEditorWin|fl|topTab;
  254.                 }else{
  255.                     tabLayout -e -sti 2 shelfEditorWin|fl|topTab;
  256.                 }
  257.  
  258.                                 textScrollList -nr 6
  259.                                     -allowMultiSelection false
  260.                                     -selectCommand "shelfEdItemChanged"
  261.                                     tsl2;
  262.  
  263.                                 button -l "Move Up" 
  264.                                     -c "shelfEdMoveItem 1" scMoveUp;
  265.  
  266.                                 button -l "Move Down"
  267.                                     -c "shelfEdMoveItem 0" scMoveDown;
  268.  
  269.                                 button -l "Delete Item" 
  270.                                     -c "shelfEdDeleteItem" 
  271.                                     rmBtn;
  272.  
  273.                                 $tfg = `textFieldGrp -l "Label & Tooltips:" 
  274.                                     -cw 1 120
  275.                                     -cat 1 "right" 5
  276.                                     -cat 2 "both" 0
  277.                                     -cc "shelfEdItemNameChanged" 
  278.                                     tfg2`;
  279.                                     
  280.                                 textFieldGrp -l "Icon Name:"
  281.                                     -cw 1 120
  282.                                     -cat 1 "right" 5
  283.                                     -cat 2 "both" 0
  284.                                     -cc "shelfEdOverlayNameChanged" 
  285.                                     tfg3;
  286.                                 checkBoxGrp    -label ""
  287.                                     -label1 "Repeatable"
  288.                                     -cw 1 120
  289.                                     -onc "shelfEdRepeatableFlagChanged"
  290.                                     -ofc "shelfEdRepeatableFlagChanged"
  291.                                     cbg1;
  292.  
  293.                                 string $separator = `separator
  294.                                     -horizontal false -height 40 -style "none"`;
  295.                                     
  296.                                 picture -image "sphere.xpm" pictCntl;                        
  297.  
  298.                                 button -l "Change Image..." 
  299.                                         -c "shelfEdModifyIcon" 
  300.                                         modBtn;
  301.                                 
  302.                                 setParent ..;
  303.                                 
  304.                                 formLayout -e 
  305.                                     -attachForm    tsl2 top    5
  306.                                     -attachForm    tsl2 right  5
  307.                                     -attachForm    tsl2 left   5
  308.                                     -attachControl tsl2 bottom 5 scMoveUp
  309.                                     
  310.                                     -attachNone     scMoveUp top
  311.                                     -attachPosition scMoveUp left   0 2
  312.                                     -attachControl  scMoveUp bottom 5 tfg2
  313.                                     -attachPosition scMoveUp right  0 32
  314.                                     
  315.                                     -attachNone     scMoveDown top
  316.                                     -attachPosition scMoveDown left   0 34
  317.                                     -attachControl  scMoveDown bottom 5 tfg2
  318.                                     -attachPosition scMoveDown right  0 65
  319.                                     
  320.                                     -attachNone     rmBtn top
  321.                                     -attachPosition rmBtn left   0 67 
  322.                                     -attachControl  rmBtn bottom 5 tfg2
  323.                                     -attachPosition rmBtn right  0 98
  324.                                     
  325.                                     -attachNone    tfg2 top
  326.                                     -attachForm    tfg2 left   0
  327.                                     -attachControl tfg2 bottom 5 tfg3
  328.                                     -attachForm    tfg2 right  0
  329.                                     
  330.                                     -attachNone    tfg3 top
  331.                                     -attachForm    tfg3 left   0
  332.                                     -attachControl tfg3 bottom 5 cbg1
  333.                                     -attachForm    tfg3 right  0 
  334.                                     
  335.                                     -attachNone    cbg1 top
  336.                                     -attachForm    cbg1 left   0
  337.                                     -attachControl cbg1 bottom 5 $separator
  338.                                     -attachForm    cbg1 right  0 
  339.  
  340.                                     -attachNone    $separator top
  341.                                     -attachForm    $separator left   120
  342.                                     -attachForm    $separator bottom 5
  343.                                     -attachNone    $separator right
  344.  
  345.                                     -aoc           pictCntl top    0 $separator
  346.                                     -attachNone    pictCntl left
  347.                                     -attachNone    pictCntl bottom
  348.                                     -attachControl pictCntl right  0 $separator
  349.  
  350.                                     -aoc           modBtn top    0 $separator
  351.                                     -attachControl modBtn left   0 $separator
  352.                                     -attachNone    modBtn bottom
  353.                                     -attachNone    modBtn right
  354.  
  355.                                     $form;
  356.  
  357.                 if(`about -mac`){
  358.                     setParent shelfEditorWin|shelfEditorWin|fl|topTab;
  359.                 }else{
  360.                     setParent shelfEditorWin|fl|topTab;
  361.                 }
  362.                     frameLayout -bv false -lv false -cll false -mw 15 -mh 10 fl4;
  363.                         formLayout frm;
  364.  
  365.                             text -l "Edit shelf button command:" scrFldTxt;
  366.  
  367.                             scrollField -h 80 -w 200
  368.                                 -enable false 
  369.                                 -ec "shelfEdCmdStringChanged"
  370.                                 scrFld;
  371.  
  372.                         if(`about -mac`){
  373.                             formLayout -e
  374.                             -af scrFldTxt "top" 0
  375.                             -af scrFldTxt "left" 0
  376.                             -af scrFld "left" 0
  377.                             -ac scrFld "top" 5 scrFldTxt
  378.                             -af scrFld "bottom" 0
  379.                             -af scrFld "right" 0
  380.                             shelfEditorWin|shelfEditorWin|fl|topTab|fl4|frm;
  381.                         }else{
  382.                             formLayout -e
  383.                                 -af scrFldTxt "top" 0
  384.                                 -af scrFldTxt "left" 0
  385.                                 -af scrFld "left" 0
  386.                                 -ac scrFld "top" 5 scrFldTxt
  387.                                 -af scrFld "bottom" 0
  388.                                 -af scrFld "right" 0
  389.                                 shelfEditorWin|fl|topTab|fl4|frm;
  390.                         }
  391.  
  392.                 if(`about -mac`){
  393.                     tabLayout -e 
  394.                     -tli 1 "Shelves"
  395.                     -tli 2 "Shelf Contents"
  396.                     -tli 3 "Edit Commands"
  397.                     shelfEditorWin|shelfEditorWin|fl|topTab;
  398.                 }else{
  399.                     tabLayout -e 
  400.                         -tli 1 "Shelves"
  401.                         -tli 2 "Shelf Contents"
  402.                         -tli 3 "Edit Commands"
  403.                         shelfEditorWin|fl|topTab;
  404.                 }
  405.  
  406.             // Add the standard 'close' button to the bottom
  407.             // along with a button to save the shelves
  408.                                 
  409.             if(`about -mac`){
  410.                 setParent shelfEditorWin|shelfEditorWin|fl; 
  411.             }else{
  412.                 setParent shelfEditorWin|fl;
  413.             } 
  414.             separator -horizontal true shelfSeparator;
  415.                 
  416.             button -l "Save All Shelves" 
  417.                 -c "shelfEdSaveAllShelves"
  418.                 saveShelvesButton;
  419.             button -l "Close" 
  420.                 -c "shelfEdCloseWindow"
  421.                 closeShelfEdButton;
  422.  
  423.             formLayout -e
  424.                 -af topTab "top" 0
  425.                 -af topTab "left" 0
  426.                 -af topTab "right" 0
  427.                 -ac topTab "bottom" 5 shelfSeparator
  428.  
  429.                 -af shelfSeparator "left" 0
  430.                 -af shelfSeparator "right" 0
  431.                 -ac shelfSeparator "bottom" 5 closeShelfEdButton
  432.  
  433.                 -af saveShelvesButton "left" 5
  434.                 -af saveShelvesButton "bottom" 5
  435.                 -ap saveShelvesButton "right" 3 50
  436.                 -an saveShelvesButton "top"
  437.  
  438.                 -ap closeShelfEdButton "left" 2 50
  439.                 -af closeShelfEdButton "bottom" 5
  440.                 -af closeShelfEdButton "right" 5
  441.                 -an closeShelfEdButton "top"
  442.                 fl;
  443.                 
  444.     } else {
  445.         if(`about -mac`){
  446.             $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  447.             $tfg = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tfg";
  448.         }else{
  449.             $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  450.             $tfg = "shelfEditorWin|fl|topTab|fl2|tfg";
  451.         }
  452.     }
  453.  
  454.     updateShelfEdView;
  455.     if (`textScrollList -q -numberOfItems $shelfList` > 0) {
  456.         textScrollList -e -si `tabLayout -q -st $gShelfTopLevel` $shelfList;
  457.         shelfEdShelfChanged;
  458.     }
  459.     showWindow shelfEditorWin;
  460. }
  461.  
  462.  
  463. global proc updateShelfEdView() 
  464. //
  465. //  Description:
  466. //        Updates the shelf list.
  467. //
  468. {
  469.  
  470.     string $shelfList;
  471.     if(`about -mac`){
  472.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  473.     }else{
  474.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  475.     }
  476.     int $i, $j;
  477.     int $nShelves = `optionVar -q numShelves`;
  478.  
  479.     textScrollList -e -removeAll $shelfList;
  480.  
  481.     for ($i = 1; $i <= $nShelves; $i++) {
  482.         textScrollList -e -a `optionVar -q ("shelfName" + $i)` $shelfList;
  483.     }
  484. }
  485.  
  486. global proc shelfEdShelfChanged() 
  487. //
  488. //  Description:
  489. //        Updates the dialog based on a change in the selected shelf.
  490. //
  491. {
  492.  
  493.     global string $gShelfTopLevel;
  494.  
  495.     string $shelfList;
  496.     string $tfg;     
  497. //    string $cbg;  
  498.     string $itemList; 
  499.     string $tfg2;   
  500.     if(`about -mac`){
  501.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  502.         $tfg =       "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tfg";
  503. //        $cbg =       "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|cbg";
  504.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  505.         $tfg2 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tfg2";
  506.     }else{
  507.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  508.         $tfg =       "shelfEditorWin|fl|topTab|fl2|tfg";
  509. //        $cbg =       "shelfEditorWin|fl|topTab|fl2|cbg";
  510.         $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  511.         $tfg2 =      "shelfEditorWin|fl|topTab|fl3|tfg2";
  512.     }
  513.     string $retVal[];
  514.     string $name;
  515.     string $type;
  516.     int $i, $nArr;
  517.  
  518.     //  update shelf text field
  519.     //
  520.     $retVal = `textScrollList -q -si $shelfList`;
  521.     textFieldGrp -e -tx $retVal[0] $tfg;
  522.     
  523.     //  select tab in shelf
  524.     //
  525.     if (`tabLayout -exists $gShelfTopLevel`) {
  526.         tabLayout -e -selectTab $retVal[0] $gShelfTopLevel;
  527.     }
  528.  
  529.     //  update shelf contents text scroll list
  530.     //
  531.     textScrollList -e -removeAll $itemList;
  532.     $retVal = `shelfLayout -q -ca $retVal[0]`;
  533.     $nArr = size($retVal);
  534.     for ($i = 0; $i < $nArr; $i++) {
  535.         $type = `objectType $retVal[$i]`;
  536.         switch ($type) {
  537.         case "toolButton":
  538.             $name = `toolButton -q -tool $retVal[$i]`;
  539.             break;
  540.         case "shelfButton":
  541.             $name = `shelfButton -q -label $retVal[$i]`;
  542.             if ($name == "") {
  543.                 $name = "  ";
  544.             }
  545.             break;
  546.         }
  547.         textScrollList -e -a $name $itemList;
  548.     }
  549.  
  550.     if ($nArr > 0) {
  551.         textScrollList -e -sii 1 $itemList;
  552.     }
  553.         
  554.     shelfEdItemChanged;
  555.  
  556. }
  557.  
  558. global proc shelfEdNameChanged() {
  559.  
  560.     global string $gShelfTopLevel;
  561.     string $shelfList;
  562.     string $tfg;
  563.     if(`about -mac`){
  564.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  565.         $tfg =       "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tfg";    
  566.     }else{
  567.          $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  568.          $tfg =       "shelfEditorWin|fl|topTab|fl2|tfg";
  569.      }
  570.     string $newName;
  571.     string $oldName;
  572.     string $fileName;
  573.     string $shelfName;
  574.     string $oldFileName;
  575.     int       $i,$j;
  576.     int    $selected[];
  577.     string $listItems[];
  578.     int       $isOkay = true;
  579.  
  580.     //  update controls
  581.     //
  582.     $listItems = `textScrollList -q -si $shelfList`;
  583.     $oldName = $listItems[0];
  584.     $newName = `textFieldGrp -q -tx $tfg`;
  585.     $selected = `textScrollList -q -sii $shelfList`;
  586.  
  587.     //  test to make sure the new name is okay
  588.     //
  589.     if (validateShelfName($newName)) {         
  590.         //
  591.         //  Everything looks okay to change the name
  592.         //
  593.         textScrollList -e -deselectAll $shelfList;
  594.         textScrollList -e -rii $selected[0] $shelfList;
  595.         textScrollList -e -ap $selected[0] $newName -sii $selected[0] $shelfList;
  596.  
  597.         //  update prefs
  598.         //
  599.         optionVar -sv ("shelfName" + $selected[0]) $newName;
  600.         optionVar -sv ("shelfFile" + $selected[0]) ("shelf_" + $newName);
  601.  
  602.         //  rename shelfLayout
  603.         //
  604.         setParent $gShelfTopLevel;
  605.         renameUI $oldName $newName;
  606.  
  607.         //  rename the tab
  608.         //
  609.         tabLayout -e -tl $newName $newName $gShelfTopLevel;
  610.  
  611.         //  rename file
  612.         //
  613.         $oldFileName = (`internalVar -userShelfDir` + "shelf_" + $oldName + ".mel");
  614.         if (`file -q -exists $oldFileName`) {
  615.             saveShelf $newName (`internalVar -userShelfDir` + "shelf_" + $newName);
  616.             sysFile -delete $oldFileName;
  617.         }
  618.     } else {
  619.         // Put the old name back
  620.         textFieldGrp -e -tx $oldName $tfg;
  621.     }
  622. }
  623.  
  624. global proc shelfEdItemChanged() {
  625.  
  626.     global string $gShelfTopLevel;
  627.  
  628.     string $shelfList;
  629.     string $itemList;
  630.     string $tfg2;
  631.     string $tfg3;
  632.     string $cbg;
  633.     string $pictCntl; 
  634.     string $modBtn; 
  635.     string $upBtn;  
  636.     string $downBtn;
  637.     string $delBtn; 
  638.     string $scrFld; 
  639.     string $statTxt;
  640.     if(`about -mac`){
  641.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  642.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  643.         $tfg2 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tfg2";
  644.         $tfg3 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tfg3";
  645.         $cbg  =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|cbg1";
  646.         $pictCntl =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|pictCntl";
  647.         $modBtn =    "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|modBtn";
  648.         $upBtn =     "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|scMoveUp";
  649.         $downBtn =   "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|scMoveDown";
  650.         $delBtn =    "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|rmBtn";
  651.         $scrFld =    "shelfEditorWin|shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  652.         $statTxt =   "shelfEditorWin|shelfEditorWin|fl|topTab|fl4|frm|scrFldTxt";
  653.     }else{
  654.          $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  655.          $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  656.          $tfg2 =      "shelfEditorWin|fl|topTab|fl3|tfg2";
  657.          $tfg3 =      "shelfEditorWin|fl|topTab|fl3|tfg3";
  658.          $cbg  =      "shelfEditorWin|fl|topTab|fl3|cbg1";
  659.          $pictCntl =  "shelfEditorWin|fl|topTab|fl3|pictCntl";
  660.          $modBtn =    "shelfEditorWin|fl|topTab|fl3|modBtn";
  661.          $upBtn =     "shelfEditorWin|fl|topTab|fl3|scMoveUp";
  662.          $downBtn =   "shelfEditorWin|fl|topTab|fl3|scMoveDown";
  663.          $delBtn =    "shelfEditorWin|fl|topTab|fl3|rmBtn";
  664.          $scrFld =    "shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  665.          $statTxt =   "shelfEditorWin|fl|topTab|fl4|frm|scrFldTxt";
  666.     }
  667.     string $item;
  668.     string $image;
  669.     string $overlayLabel;
  670.     string $selected[];
  671.     string $retVal[];
  672.     string $type;
  673.     string $cmdStr;
  674.     int $itemIndex[];
  675.     int $index;
  676.     int $i, $nArr;
  677.     int $repeatFlag = false;
  678.     //  update item text field
  679.     //
  680.     $retVal = `textScrollList -q -si $itemList`;
  681.     if (size($retVal) > 0) {
  682.         textFieldGrp -e -tx $retVal[0] $tfg2;
  683.  
  684.         //  get real item name
  685.         //
  686.         $itemIndex = `textScrollList -q -sii $itemList`;
  687.         $index = $itemIndex[0] - 1;
  688.         $selected = `textScrollList -q -si $shelfList`;
  689.         $retVal = `shelfLayout -q -ca $selected[0]`;
  690.         $item = ($gShelfTopLevel + "|" + $selected[0] + "|" + $retVal[$index]);
  691.         $type = `objectType $item`;
  692.  
  693.         switch ($type) {
  694.         case "toolButton":
  695.             $overlayLabel = `toolButton -q -iol $item`;
  696.             textFieldGrp -e -tx  $overlayLabel $tfg3;            
  697.             $image = `toolButton -q -image1 $item`;
  698.             scrollField -e -enable false -clear $scrFld;
  699.             textFieldGrp -e -enable true $tfg2;
  700.             text -e -l "Cannot edit tool button contents." $statTxt;
  701.             break;
  702.         case "shelfButton":
  703.             $overlayLabel = `shelfButton -q -iol $item`;
  704.             textFieldGrp -e -tx  $overlayLabel $tfg3;            
  705.             $repeatFlag = `shelfButton -q -ecr $item`;
  706.             checkBoxGrp -edit -value1 $repeatFlag $cbg;
  707.  
  708.             $image = `shelfButton -q -image1 $item`;
  709.             $cmdStr = `shelfButton -q -c $item`;
  710.             scrollField -e -enable true -text $cmdStr $scrFld;
  711.             textFieldGrp -e -enable true $tfg2;
  712.             text -e -l "Edit the shelf button command. Press keypad Enter to Save." $statTxt;
  713.             break;
  714.         }
  715.         picture -e -image $image $pictCntl;
  716.         textFieldGrp -e -enable true $tfg3;
  717.         button -e -enable true $modBtn;
  718.         button -e -enable true $upBtn;
  719.         button -e -enable true $downBtn;
  720.         button -e -enable true $delBtn;
  721.         checkBoxGrp -e -enable true $cbg;
  722.  
  723.         if (`window -exists pickPixMapWin`) {
  724.             xpmShelfItemChanged $image $item;
  725.         }
  726.     } else {
  727.         // no items or nothing selected
  728.         //
  729.         picture -e -image "" $pictCntl;
  730.         scrollField -e -enable false -clear $scrFld;
  731.         textFieldGrp -e -enable false -text "" $tfg2;    
  732.         textFieldGrp -e -enable false $tfg3;
  733.         button -e -enable false $modBtn;
  734.         button -e -enable false $upBtn;
  735.         button -e -enable false $downBtn;
  736.         button -e -enable false $delBtn;
  737.         checkBoxGrp -e -enable false $cbg;
  738.         text -e -l "No item selected." $statTxt;
  739.  
  740.         if (`window -exists pickPixMapWin`) {
  741.             string $empty = "";
  742.             xpmShelfItemChanged $empty $empty;
  743.         }
  744.     }
  745. }
  746.  
  747. global proc shelfEdCmdStringChanged() 
  748. //
  749. //  Description:
  750. //        Callback for change in a command button's cmd string.
  751. //
  752. {
  753.     global string $gShelfTopLevel;
  754.  
  755.     string $shelfList;
  756.     string $itemList;
  757.     string $scrFld;
  758.     if(`about -mac`){
  759.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  760.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  761.         $scrFld =    "shelfEditorWin|shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  762.     }else{
  763.          $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  764.          $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  765.          $scrFld =    "shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  766.     }
  767.     string $selected[];
  768.     string $childs[];
  769.     int    $selItems[];
  770.     string $item;
  771.  
  772.     $selItems = `textScrollList -q -sii $itemList`;
  773.     $selected = `textScrollList -q -si $shelfList`;
  774.     $childs = `shelfLayout -q -ca ($gShelfTopLevel + "|" + $selected[0])`;
  775.  
  776.     if ($selItems[0] <= size($childs)) {
  777.         $item = ($gShelfTopLevel + "|" + $selected[0] + "|" 
  778.                  + $childs[($selItems[0]-1)]);
  779.         shelfButton -e -c `scrollField -q -text $scrFld` $item;
  780.     }
  781. }
  782.  
  783. global proc shelfEdNewShelf()
  784. //
  785. //  Description:
  786. //        Add a new empty shelf tab.
  787. //
  788. {
  789.     string $shelfList;
  790.     if(`about -mac`){
  791.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  792.     }else{
  793.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  794.     }
  795.     int $index;
  796.  
  797.     addNewShelfTab "";
  798.     updateShelfEdView;
  799.  
  800.     $index = `textScrollList -q -numberOfItems $shelfList`;
  801.     textScrollList -e -sii $index $shelfList;
  802.     shelfEdShelfChanged;
  803. }
  804.  
  805. global proc shelfEdDeleteShelf()
  806. //
  807. //  Description:
  808. //        Deletes the selected shelf tab.
  809. //
  810. {
  811.     string $shelfList;
  812.     if(`about -mac`){
  813.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  814.     }else{
  815.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  816.     }
  817.     string $shelfName[] = `textScrollList -q -si $shelfList`;
  818.     int $indexArr[];
  819.     int $index = 0;
  820.     int $nItems = 0;
  821.  
  822.     $indexArr = `textScrollList -q -sii $shelfList`;
  823.     if (`deleteShelfTab $shelfName[0]`) {
  824.         updateShelfEdView;
  825.  
  826.         $index = $indexArr[0];
  827.         $nItems = `textScrollList -q -ni $shelfList`;
  828.         if ($nItems > 0) {
  829.             if ($nItems < $index) {
  830.                 $index = $nItems;
  831.             }
  832.             textScrollList -e -sii $index $shelfList;
  833.         }
  834.         shelfEdShelfChanged;
  835.     }
  836. }
  837.  
  838. global proc shelfEdItemNameChanged() {
  839.  
  840.     global string $gShelfTopLevel;
  841.  
  842.     string $shelfList;
  843.     string $itemList; 
  844.     string $tfg2;
  845.     if(`about -mac`){
  846.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  847.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  848.         $tfg2 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tfg2";
  849.     }else{
  850.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  851.         $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  852.         $tfg2 =      "shelfEditorWin|fl|topTab|fl3|tfg2";
  853.     }
  854.     string $item;
  855.     string $itemStr;
  856.     string $retVal[];
  857.     string $selected[];
  858.     string $type;
  859.     int $index;
  860.     int $itemIndex[];
  861.     int $i, $nArr;
  862.     int       $isOkay = true;
  863.     string $newName;
  864.     string $oldName;
  865.  
  866.     $retVal = `textScrollList -q -si $itemList`;
  867.     if (size($retVal) > 0) {
  868.         $itemStr = $retVal[0];
  869.         //  get new name
  870.         //
  871.         $newName = `textFieldGrp -q -tx $tfg2`;
  872.         $oldName = $retVal[0];
  873.  
  874.         //      test for zero length name
  875.         //
  876.         if (size($newName) == 0) {
  877.             $isOkay = false;
  878.             confirmDialog -title "Alert" 
  879.                 -button "OK"
  880.                 -defaultButton "OK"
  881.                 -message "       Invalid item name. Please select another.        "
  882.                 -parent shelfEditorWin;
  883.  
  884.             textFieldGrp -e -tx $oldName $tfg2;
  885.         } else {
  886.             //  get real item name
  887.             //
  888.             $itemIndex = `textScrollList -q -sii $itemList`;
  889.             $index = $itemIndex[0] - 1;
  890.             $selected = `textScrollList -q -si $shelfList`;
  891.             $retVal = `shelfLayout -q -ca $selected[0]`;
  892.             $item = ($gShelfTopLevel + "|" + $selected[0] + "|" + $retVal[$index]);
  893.             $type = `objectType $item`;
  894.  
  895.             switch ($type) {
  896.             case "toolButton":
  897.                 if (catch(`renameUI $itemStr $newName`)) {
  898.                     //
  899.                     // error due to non - unique name for context
  900.                     //
  901.                     confirmDialog -title "Alert" 
  902.                         -button "OK"
  903.                         -defaultButton "OK"
  904.                         -message "       Context name is not unique.  Please select another        "
  905.                         -parent shelfEditorWin;
  906.                     
  907.                     $isOkay = false;
  908.                 }
  909.                 break;
  910.             case "shelfButton":
  911.                 shelfButton -e -l $newName $item;
  912.                 break;
  913.             }
  914.             
  915.             if ($isOkay) {
  916.                 shelfEdShelfChanged;
  917.                 textScrollList -e -sii $itemIndex[0] $itemList;
  918.                 shelfEdItemChanged;
  919.             }
  920.         }
  921.     }
  922. }
  923.  
  924.  
  925. global proc shelfEdOverlayNameChanged() {
  926.  
  927.     global string $gShelfTopLevel;
  928.  
  929.     string $shelfList;
  930.     string $itemList;
  931.     string $tfg2;
  932.     string $tfg3;  
  933.     if(`about -mac`){
  934.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  935.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  936.         $tfg2 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tfg2";
  937.         $tfg3 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tfg3";
  938.     }else{
  939.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  940.         $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  941.         $tfg2 =      "shelfEditorWin|fl|topTab|fl3|tfg2";
  942.         $tfg3 =      "shelfEditorWin|fl|topTab|fl3|tfg3";
  943.     }
  944.     string $item;
  945.     string $itemStr;
  946.     string $retVal[];
  947.     string $selected[];
  948.     string $type;
  949.     int $index;
  950.     int $itemIndex[];
  951.     int $i, $nArr;
  952.     int       $isOkay = true;
  953.     string $newName;
  954.  
  955.     $retVal = `textScrollList -q -si $itemList`;
  956.     if (size($retVal) > 0) {
  957.         $itemStr = $retVal[0];
  958.         //  get new name
  959.         //
  960.         $newName = `textFieldGrp -q -tx $tfg3`;
  961.  
  962.         //      test for bad characters
  963.         //
  964.         string $regex = "[^0-9a-zA-Z_-\ ]";
  965.         string $match = match( $regex, $newName );
  966.         if ($match != "") {
  967.             $isOkay = false;
  968.             confirmDialog -title "Alert" 
  969.                 -button "OK"
  970.                 -defaultButton "OK"
  971.                 -message "       Item name contains illegal characters. Please select another.        "
  972.                 -parent shelfEditorWin;
  973.         } else {
  974.             //  get real item name
  975.             //
  976.             $itemIndex = `textScrollList -q -sii $itemList`;
  977.             $index = $itemIndex[0] - 1;
  978.             $selected = `textScrollList -q -si $shelfList`;
  979.             $retVal = `shelfLayout -q -ca $selected[0]`;
  980.             $item = ($gShelfTopLevel + "|" + $selected[0] + "|" + $retVal[$index]);
  981.             $type = `objectType $item`;
  982.  
  983.             switch ($type) {
  984.             case "toolButton":
  985.                 toolButton -e -iol $newName $item;
  986.                 break;
  987.             case "shelfButton":
  988.                 shelfButton -e -iol $newName $item;
  989.                 break;
  990.             }
  991.             
  992.             if ($isOkay) {
  993.                 shelfEdShelfChanged;
  994.                 textScrollList -e -sii $itemIndex[0] $itemList;
  995.                 shelfEdItemChanged;
  996.             }
  997.         }
  998.     }
  999. }
  1000.  
  1001.  
  1002.  
  1003. global proc shelfEdDeleteItem()
  1004. {
  1005.     global string $gShelfTopLevel;
  1006.  
  1007.     string $shelfList;
  1008.     string $itemList;
  1009.     string $tfg2;
  1010.     string $pictCntl;
  1011.     string $scrFld;
  1012.     if(`about -mac`){
  1013.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  1014.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  1015.         $tfg2 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tfg2";
  1016.         $pictCntl =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|pictCntl";
  1017.         $scrFld =    "shelfEditorWin|shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  1018.     }else{
  1019.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  1020.         $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  1021.         $tfg2 =      "shelfEditorWin|fl|topTab|fl3|tfg2";
  1022.         $pictCntl =  "shelfEditorWin|fl|topTab|fl3|pictCntl";
  1023.         $scrFld =    "shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  1024.     }
  1025.     string $selected[];
  1026.     string $retVal[];
  1027.     string $item;
  1028.     string $type;
  1029.     string $ctx[];
  1030.     int $itemIndex[];
  1031.     int $index;
  1032.     int $nItems;
  1033.     int $i, $nArr;
  1034.  
  1035.     //  update item text field
  1036.     //
  1037.     $retVal = `textScrollList -q -si $itemList`;
  1038.     if (size($retVal) > 0) {
  1039.         //  get real item name
  1040.         //
  1041.         $itemIndex = `textScrollList -q -sii $itemList`;
  1042.         $index = $itemIndex[0] - 1;
  1043.         $selected = `textScrollList -q -si $shelfList`;
  1044.         $retVal = `shelfLayout -q -ca $selected[0]`;
  1045.         $item = ($gShelfTopLevel + "|" + $selected[0] + "|" + $retVal[$index]);
  1046.         $type = `objectType $item`;
  1047.  
  1048.         if ($type == "toolButton") {
  1049.             $ctx = `toolButton -q -toolArray $item`;
  1050.             $nArr = size($ctx);
  1051.             for ($i = 0; $i < $nArr; $i++) {
  1052.                 deleteUI -toolContext $ctx[$i];
  1053.             }
  1054.         }
  1055.         deleteUI -control $item;
  1056.  
  1057.         shelfEdShelfChanged;
  1058.  
  1059.         $nItems = `textScrollList -q -ni $itemList`;
  1060.         if ($itemIndex[0] < $nItems) {
  1061.             textScrollList -e -sii $itemIndex[0] $itemList;
  1062.         } else if ($nItems > 0) {
  1063.             textScrollList -e -sii $nItems $itemList;
  1064.         }
  1065.         shelfEdItemChanged;
  1066.     }
  1067. }
  1068.  
  1069. global proc shelfEdModifyIcon() {
  1070.  
  1071.  
  1072.     global string $gShelfTopLevel;
  1073.  
  1074.     string $shelfList; 
  1075.     string $itemList;
  1076.     string $tfg2;
  1077.     string $scrFld;
  1078.     if(`about -mac`){
  1079.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  1080.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  1081.         $tfg2 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tfg2";
  1082.         $scrFld =    "shelfEditorWin|shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  1083.     }else{
  1084.          $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  1085.          $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  1086.          $tfg2 =      "shelfEditorWin|fl|topTab|fl3|tfg2";
  1087.          $scrFld =    "shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  1088.     }
  1089.     string $item;
  1090.     string $image;
  1091.     string $selected[];
  1092.     string $retVal[];
  1093.     string $type;
  1094.     int $itemIndex[];
  1095.     int $index;
  1096.     int $i;
  1097.  
  1098.     $retVal = `textScrollList -q -si $itemList`;
  1099.     if (size($retVal) > 0) {
  1100.         textFieldGrp -e -tx $retVal[0] $tfg2;
  1101.  
  1102.         //  get real item name
  1103.         //
  1104.         $itemIndex = `textScrollList -q -sii $itemList`;
  1105.         $index = $itemIndex[0] - 1;
  1106.         $selected = `textScrollList -q -si $shelfList`;
  1107.         $retVal = `shelfLayout -q -ca $selected[0]`;
  1108.         $item = ($gShelfTopLevel + "|" + $selected[0] + "|" + $retVal[$index]);
  1109.         $type = `objectType $item`;
  1110.  
  1111.         switch ($type) {
  1112.         case "toolButton":
  1113.             $image = `toolButton -q -image1 $item`;
  1114.             break;
  1115.         case "shelfButton":
  1116.             $image = `shelfButton -q -image1 $item`;
  1117.             break;
  1118.         }
  1119.  
  1120.         if (`about -nt`) {
  1121.             pickXPMWin32 $image "shelfEditorWin";
  1122.         } else {
  1123.             if( `about -mac`)
  1124.             {
  1125.                 string $newName;
  1126.                 int $fileTest;
  1127.                 string $dirName = getenv("MAYA_LOCATION");
  1128.                 $dirName = dirname($dirName);
  1129.                 $dirName = dirname($dirName) + "/extras/icons";
  1130.                 $dirName = $dirName+"/*.xpm";
  1131.                 $newName = `fileDialog -dm  $dirName`;
  1132.                 if ($newName == "") return; // cancel hit
  1133.                 $fileTest = `filetest -s $newName`;
  1134.                 if($fileTest == 0) {
  1135.                     $newName = "";
  1136.                     error("Invalid icon file\n");
  1137.                     return;
  1138.                 }
  1139.                 shelfEdButtonImageChanged $newName;    
  1140.             } else { //Unix family
  1141.                 pickXPM $image $item;
  1142.             }
  1143.         }
  1144.     } else {
  1145.         // no items or nothing selected
  1146.         //
  1147.     }
  1148. }
  1149.  
  1150. global proc shelfEdButtonImageChanged (string $newXpmFile) {
  1151.  
  1152.  
  1153.     global string $gShelfTopLevel;
  1154.  
  1155.     string $shelfList;
  1156.     string $itemList;
  1157.     string $tfg2;
  1158.     string $pictCntl;
  1159.     string $scrFld;
  1160.     if(`about -mac`){
  1161.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  1162.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  1163.         $tfg2 =      "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tfg2";
  1164.         $pictCntl =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|pictCntl";
  1165.         $scrFld =    "shelfEditorWin|shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  1166.     }else{
  1167.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  1168.         $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  1169.         $tfg2 =      "shelfEditorWin|fl|topTab|fl3|tfg2";
  1170.         $pictCntl =  "shelfEditorWin|fl|topTab|fl3|pictCntl";
  1171.         $scrFld =    "shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  1172.     }
  1173.     string $item;
  1174.     string $image;
  1175.     string $selected[];
  1176.     string $retVal[];
  1177.     string $type;
  1178.     int $itemIndex[];
  1179.     int $index;
  1180.     int $i;
  1181.  
  1182.     $retVal = `textScrollList -q -si $itemList`;
  1183.     if (size($retVal) > 0) {
  1184.         textFieldGrp -e -tx $retVal[0] $tfg2;
  1185.  
  1186.         //  get real item name
  1187.         //
  1188.         $itemIndex = `textScrollList -q -sii $itemList`;
  1189.         $index = $itemIndex[0] - 1;
  1190.         $selected = `textScrollList -q -si $shelfList`;
  1191.         $retVal = `shelfLayout -q -ca $selected[0]`;
  1192.         $item = ($gShelfTopLevel + "|" + $selected[0] + "|" + $retVal[$index]);
  1193.         $type = `objectType $item`;
  1194.  
  1195.         switch ($type) {
  1196.         case "toolButton":
  1197.             toolButton -e -image1 $newXpmFile $item;
  1198.             break;
  1199.         case "shelfButton":
  1200.             shelfButton -e -image1 $newXpmFile $item;
  1201.             break;
  1202.         }
  1203.         picture -e -image $newXpmFile $pictCntl;
  1204.     } else {
  1205.         // no items or nothing selected
  1206.         //
  1207.     }
  1208.  
  1209. }
  1210.  
  1211. global proc shelfEdMoveShelf( int $isLeft ) {
  1212.  
  1213.     global string $gShelfTopLevel;
  1214.  
  1215.     string $shelfList;
  1216.     if(`about -mac`){
  1217.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  1218.     }else{
  1219.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  1220.     }
  1221.     int $indexArr[];
  1222.     int $from, $to;
  1223.     int $move = false;
  1224.  
  1225.     $indexArr = `textScrollList -q -sii $shelfList`;
  1226.     $from = $indexArr[0];
  1227.     
  1228.     if ($isLeft) {
  1229.         if ($from > 1) {
  1230.             $to = $indexArr[0]-1;
  1231.             $move = true;
  1232.         }
  1233.     } else {
  1234.         if ($from < `tabLayout -q -nch $gShelfTopLevel`) {
  1235.             $to = $indexArr[0]+1;
  1236.             $move = true;
  1237.         }
  1238.     }    
  1239.  
  1240.     if ($move) {
  1241.         int    $load;
  1242.         string $name, $file;
  1243.  
  1244.         tabLayout -e -moveTab $from $to $gShelfTopLevel;
  1245.  
  1246.         $load = `optionVar -q ("shelfLoad" + $from)`;
  1247.         $name = `optionVar -q ("shelfName" + $from)`;
  1248.         $file = `optionVar -q ("shelfFile" + $from)`;
  1249.  
  1250.         optionVar 
  1251.             -iv ("shelfLoad" + $from) `optionVar -q ("shelfLoad" + $to)`
  1252.             -sv ("shelfName" + $from) `optionVar -q ("shelfName" + $to)`
  1253.             -sv ("shelfFile" + $from) `optionVar -q ("shelfFile" + $to)`;
  1254.  
  1255.         optionVar
  1256.             -iv ("shelfLoad" + $to) $load
  1257.             -sv ("shelfName" + $to) $name
  1258.             -sv ("shelfFile" + $to) $file;
  1259.  
  1260.         updateShelfEdView;
  1261.         textScrollList -e -sii $to $shelfList;
  1262.     }
  1263.  
  1264. }
  1265.  
  1266. global proc shelfEdMoveItem( int $isLeft ) {
  1267.  
  1268.     global string $gShelfTopLevel;
  1269.  
  1270.     string $shelfList;
  1271.     string $itemList;
  1272.     if(`about -mac`){
  1273.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  1274.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  1275.     }else{
  1276.         $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  1277.         $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  1278.     }
  1279.     string $selected[];
  1280.     string $retVal[];
  1281.     int $indexArr[];
  1282.     int $from, $to;
  1283.     int $move = false;
  1284.  
  1285.     $selected = `textScrollList -q -si $shelfList`;
  1286.     $itemIndex = `textScrollList -q -sii $itemList`;
  1287.     $retVal = `shelfLayout -q -ca ($gShelfTopLevel + "|" + $selected[0])`;
  1288.     $from = $itemIndex[0];
  1289.     
  1290.     if ($isLeft) {
  1291.         if ($from > 1) {
  1292.             $to = $itemIndex[0]-1;
  1293.             $move = true;
  1294.         }
  1295.     } else {
  1296.         if ($from < `shelfLayout -q -nch $selected`) {
  1297.             $to = $itemIndex[0]+1;
  1298.             $move = true;
  1299.         }
  1300.     }    
  1301.  
  1302.     if ($move) {
  1303.         int    $nArr;
  1304.         string $type;
  1305.  
  1306.         //
  1307.         //  move the item
  1308.         //
  1309.         shelfLayout -e -position $retVal[$from-1] $to 
  1310.             ($gShelfTopLevel + "|" + $selected[0]);
  1311.  
  1312.         //
  1313.         //  update the item list
  1314.         //
  1315.         textScrollList -e -removeAll $itemList;
  1316.         $retVal = `shelfLayout -q -ca ($gShelfTopLevel + "|" + $selected[0])`;
  1317.         $nArr = size($retVal);
  1318.         for ($i = 0; $i < $nArr; $i++) {
  1319.             $type = `objectType $retVal[$i]`;
  1320.             switch ($type) {
  1321.             case "toolButton":
  1322.                 $name = `toolButton -q -tool $retVal[$i]`;
  1323.                 break;
  1324.             case "shelfButton":
  1325.                 $name = `shelfButton -q -label $retVal[$i]`;
  1326.                 if ($name == "") {
  1327.                     $name = "  ";
  1328.                 }
  1329.                 break;
  1330.             }
  1331.             textScrollList -e -a $name $itemList;
  1332.         }
  1333.         textScrollList -e -sii $to $itemList;
  1334.     }
  1335.  
  1336. }
  1337.  
  1338.  
  1339. global proc shelfEdTabPreSelect() 
  1340. //
  1341. //  Description:
  1342. //        This proc is called when a tab label is clicked on.  Check if
  1343. //        the contents of the command button have been modified and 
  1344. //        if so offer a chance to save.
  1345. //
  1346. {
  1347.     shelfEdCheckForCommandChange;
  1348. }
  1349.  
  1350. global proc shelfEdSaveAllShelves() 
  1351. //
  1352. //  Description:
  1353. //        The Save All Shelves button has been pressed.
  1354. //
  1355. {
  1356.     global string $gShelfTopLevel;
  1357.     string $topTab;
  1358.     if(`about -mac`){
  1359.         $topTab = "shelfEditorWin|shelfEditorWin|fl|topTab";
  1360.     }else{
  1361.         $topTab = "shelfEditorWin|fl|topTab";
  1362.     }
  1363.  
  1364.     if (`tabLayout -q -sti $topTab` == 3) {
  1365.         //
  1366.         //  Leaving the edit commands tab.  Check if the contents have 
  1367.         //  changed and offer a chance to save.
  1368.         //
  1369.         shelfEdCheckForCommandChange;
  1370.     }
  1371.  
  1372.     saveAllShelves $gShelfTopLevel;
  1373.     window -e -visible false shelfEditorWin;
  1374. }
  1375.  
  1376. global proc shelfEdCloseWindow() 
  1377. //
  1378. //  Description:
  1379. //        The Close button has been pressed.
  1380. //
  1381. {
  1382.     string $topTab;
  1383.     
  1384.     if(`about -mac`){
  1385.         $topTab = "shelfEditorWin|shelfEditorWin|fl|topTab";
  1386.     }else{
  1387.         $topTab = "shelfEditorWin|fl|topTab";
  1388.     }
  1389.  
  1390.     if (`tabLayout -q -sti $topTab` == 3) {
  1391.         //
  1392.         //  Leaving the edit commands tab.  Check if the contents have 
  1393.         //  changed and offer a chance to save.
  1394.         //
  1395.         shelfEdCheckForCommandChange;
  1396.     }
  1397.  
  1398.     window -e -visible false shelfEditorWin;
  1399. }
  1400.  
  1401. global proc shelfEdCheckForCommandChange() 
  1402. //
  1403. //  Description:
  1404. //        Check if the contents of the command button have been modified and 
  1405. //        if so offer a chance to save.
  1406. //
  1407. {
  1408.     global string $gShelfTopLevel;
  1409.  
  1410.     string $shelfList;
  1411.     string $itemList;
  1412.     string $scrFld;
  1413.     if(`about -mac`){
  1414.         $shelfList = "shelfEditorWin|shelfEditorWin|fl|topTab|fl2|tsl";
  1415.         $itemList =  "shelfEditorWin|shelfEditorWin|fl|topTab|fl3|tsl2";
  1416.         $scrFld =    "shelfEditorWin|shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  1417.     }else{
  1418.          $shelfList = "shelfEditorWin|fl|topTab|fl2|tsl";
  1419.          $itemList =  "shelfEditorWin|fl|topTab|fl3|tsl2";
  1420.          $scrFld =    "shelfEditorWin|fl|topTab|fl4|frm|scrFld";
  1421.     }
  1422.     string $selected[];
  1423.     string $childs[];
  1424.     int    $selItems[];
  1425.     string $item;
  1426.     string $itemCmd;
  1427.     string $scrFieldText;
  1428.     
  1429.     if (!`textScrollList -exists $itemList`) return;
  1430.  
  1431.     $selItems = `textScrollList -q -sii $itemList`;
  1432.     $selected = `textScrollList -q -si $shelfList`;
  1433.     $childs = `shelfLayout -q -ca ($gShelfTopLevel + "|" + $selected[0])`;
  1434.  
  1435.     if (size($selItems) > 0 && $selItems[0] <= size($childs)) {
  1436.         $item = ($gShelfTopLevel + "|" + $selected[0] + "|" 
  1437.                  + $childs[($selItems[0]-1)]);
  1438.         $itemCmd = `shelfButton -q -c $item`;
  1439.         $scrFieldText = `scrollField -q -text $scrFld`;
  1440.         if ($itemCmd != $scrFieldText) {
  1441.             string $okStr = "Save Changes";
  1442.             string $cancelStr = "Discard Changes";
  1443.             $msg = ("Contents of the shelf button have changed.  Do you want to save the changes?");
  1444.             if ($okStr == `confirmDialog -parent shelfEditorWin -title "Confirm"
  1445.                 -message $msg
  1446.                 -button $okStr -button $cancelStr -defaultButton $okStr
  1447.                 -cancelButton $cancelStr -dismissString $cancelStr`) 
  1448.             {
  1449.                 shelfButton -e -c $scrFieldText $item;
  1450.             }
  1451.             scrollField -e -text `shelfButton -q -c $item` $scrFld;
  1452.         }
  1453.     }
  1454. }
  1455.